<%--
  Created by IntelliJ IDEA.
  User: 晴
  Date: 2021/10/20
  Time: 10:19
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html>
<head>
    <title>查看订单</title>
</head>
<link type="text/css" rel="stylesheet" href="css/style.css"/>
<script src="scripts/jquery-3.1.1.min.js"></script>
<script type="text/javascript" src="scripts/function.js"></script>
<script type="text/javascript" src="../js/layer-v3.5.1/layer/layer.js"></script>
<style>
    .order li {
        text-align: center;
        line-height: 50px;
        font-size: 15px;
        width: 1200px;
    }

    #name, #num, #price, #xiaoji {
        width: 200px;
    }

    .orderid, #name {
        float: left;
    }

    .sum, #num {
        float: left;
        display: inline-block;
        width: 200px;
        margin-left: 20px;
    }

    .createdate, #price {
        float: left;
        margin-left: 20px;
    }

    .state {
        float: left;
        margin-left: 20px;
    }

    form {
        display: inline-block;
        margin-left: 10px;
    }

    #submit, button {
        font-size: 16px;
        width: 80px;
        height: 28px;
        background-color: #FC7E31;
        border-color: #357ebd;
        color: #fff;
        -moz-border-radius: 10px;
        -webkit-border-radius: 10px;
        border-radius: 10px; /* future proofing */
        -khtml-border-radius: 10px; /* for old Konqueror browsers */
        text-align: center;
        border: 1px solid transparent;
        font-weight: 900;
        cursor: pointer;
    }

    #submit:hover, button:hover {
        background-color: #ff9b12;
        cursor: pointer;
    }
</style>
<body>
<div id="header" class="wrap">
    <div id="logo"><img src="images/logo.gif"/></div>
    <div class="help"><a href="#" class="shopping">购物车</a><a href="../guestbook.jsp">留言</a><a href='LogOutServlet'>点击注销</a></div>
    <div class="navbar">
        <ul class="clearfix">
            <li class="current"><a href="#">首页</a></li>
            <li><a href="#">图书</a></li>
            <li><a href="#">百货</a></li>
            <li><a href="#">品牌</a></li>
            <li><a href="#">促销</a></li>
        </ul>
    </div>
</div>
<div id="childNav">
    <div class="wrap">
        <ul class="clearfix">
            <li class="first"><a href="#">音乐</a></li>
            <li><a href="#">影视</a></li>
            <li><a href="#">少儿</a></li>
            <li><a href="#">动漫</a></li>
            <li><a href="#">小说</a></li>
            <li><a href="#">外语</a></li>
            <li><a href="#">数码相机</a></li>
            <li><a href="#">笔记本</a></li>
            <li><a href="#">羽绒服</a></li>
            <li><a href="#">秋冬靴</a></li>
            <li><a href="#">运动鞋</a></li>
            <li><a href="#">美容护肤</a></li>
            <li><a href="#">家纺用品</a></li>
            <li><a href="#">婴幼奶粉</a></li>
            <li><a href="#">饰品</a></li>
            <li class="last"><a href="#">Investor Relations</a></li>
        </ul>
    </div>
</div>
<div id="position" class="wrap">
    您现在的位置：<a href="/shopping/TodaySpecialsServlet">易买网</a> >订单
</div>
<div class="wrap">
    <div id="shopping">
        <ul class="order">
            <c:forEach items="${sessionScope.orderList}" var="o">
                <li><span class="orderid">订单号:<a href="javascript:;" id="showmore">${o.fatherorderid}</a></span><span
                        class="sum">订单总价：${o.sum}元</span><span
                        class="createdate">创建时间:<fmt:formatDate
                        value="${o.createtime}"
                        pattern="yyyy年MM月dd日 HH时mm分ss秒"/></span>
                    <span class="state">订单状态:
                    <c:if test="${o.state==1}">
                        已支付
                    </c:if>
                    <c:if test="${o.state==2}">
                        待收货
                    </c:if>
                    <c:if test="${o.state==3}">
                        已全部收货
                    </c:if>
                    <c:if test="${o.state==4}">
                              已完成
                    </c:if>
                    <c:if test="${o.state==0}">
                        未支付<form action="/shopping/OrderPayServlet" method="get">
                        <input type="hidden" name="out_trade_no" value="${o.fatherorderid}"/>
                        <input type="hidden" name="total_amount" value="${o.sum}"/>
                        <input type="submit" value="去支付" id="submit">
                        </form>
                    </c:if></span><br/>
                    <c:forEach items="${sessionScope.orderFormList}" var="s">
                        <c:if test="${s.fatherorderid==o.fatherorderid}">
                            <c:forEach items="${sessionScope.commodityList}" var="c">
                                <c:if test="${c.commodity_id==s.com_id}">
                                    <div id="more" style="display: none">
                                        <span id="sonorderid" style="display: none">${s.sonorderid}</span>
                                        <span id="name">商品:${c.commodity_name}</span>
                                        <span id="num">数量: ${s.num}个</span>
                                        <span id="price">单价：${s.price}元</span>
                                        <span id="xiaoji">小计:${s.sonordersum}元</span>
                                        <c:if test="${s.sonorderstate==2}">
                                            等待收货<button id="affirm">确认收货</button>
                                        </c:if>
                                        <c:if test="${s.sonorderstate==3}">
                                            <button onclick="PlInsert(${c.commodity_id},${s.sonorderid})">去评价</button>
                                        </c:if>
                                        <c:if test="${s.sonorderstate==4}">
                                            已完成
                                        </c:if>
                                    </div>
                                </c:if>
                            </c:forEach>
                        </c:if>
                    </c:forEach>
                </li>
            </c:forEach>
        </ul>
        <div class="shadow">
            <em class="corner lb"></em>
            <em class="corner rt"></em>
        </div>
    </div>
</div>
<div id="footer">
    Copyright &copy; 2010 北大青鸟 All Rights Reserved. 京ICP证1000001号
</div>
</body>
<script>
    $(function () {
        $
        $(".order #affirm").on('click', function () {

            alert("确认宝贝已经在您手上了吗?")
            $.ajax({
                url: "/shopping/ConfirmReceiptServlet",
                type: "post",
                data: {
                    sonorderid: $(this).siblings("#sonorderid").text(),
                    fatherorderid: $(this).parents("li").children().find('#showmore').text()
                },
                success: function (data) {
                    alert("已确认收货！")
                    location.reload();
                }
            })
        })
        $(".order #showmore").on('click', function () {
            if ($(this).parent().siblings("#more").is(':hidden')) {
                $(this).parent().siblings("#more").slideDown("normal");
            } else {
                $(this).parent().siblings("#more").slideUp("normal");
            }
        })
    })
</script>
<script>

    function PlInsert(id, orderid) {
        layer.open({
            type: 1,
            title: '评论',
            content: '<form action="MessageServlet" method="post">\n' +
                '                    <table>\n' +
                '                        <input type="hidden" name="op" value="PLinsert">\n' +
                '                        <input type="hidden" name="id" value="' + id + '">\n' +
                '                        <input type="hidden" name="orderid" value="' + orderid + '">\n' +
                '                        <tr>\n' +
                '                            <td class="field">留言内容：</td>\n' +
                '                            <td><textarea name="guestContent"></textarea></td>\n' +
                '                        </tr>\n' +
                '                        <tr>\n' +
                '                            <td></td>\n' +
                '                            <td><label class="ui-blue"><input type="submit" name="submit" value="提交留言" /></label></td>\n' +
                '                        </tr>\n' +
                '                    </table>\n' +
                '                </form>'

        })
    }
</script>
</html>
